package com.iwdnb.gkgz.application.service.impl;

import java.util.List;

import com.iwdnb.bmnf.common.utils.BeanConvertUtils;
import com.iwdnb.gkgz.application.service.StockService;
import com.iwdnb.gkgz.common.model.dto.Stock;
import com.iwdnb.gkgz.infrastructure.dao.repo.StockRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 默认国内
 *
 * @author wbc
 * @date 2020/11/9
 */
@Component
@Slf4j
public class StockServiceImpl implements StockService {

    @Autowired
    StockRepository stockRepository;

    @Override
    public List<Stock> queryStockList() {
        List<Stock> stockList = stockRepository.findAll();
        return BeanConvertUtils.convertList(stockList, Stock.class);
    }

    @Override
    public List<Stock> findByCodes(List<String> codes) {
        return stockRepository.findByCodes(codes);
    }

    @Override
    public void saveAll(List<Stock> stockList) {
        stockRepository.saveAll(stockList);
    }

    @Override
    public void save(Stock stock) {
        stockRepository.save(stock);
    }

}
